package org.rambadger.command.event;


import org.hibernate.validator.constraints.Length;
import org.rambadger.command.validation.UrlIdentifier;

import javax.validation.constraints.Min;
import javax.validation.constraints.NotNull;
import java.io.Serializable;

/**
* The user edited the text for one of their submissions.
*/
public class SubmissionMessageEdited implements Serializable {
    private static final long serialVersionUID = -5141848318417078328L;
    //Compound Key {
    private final String username;
    private final int submissionId;
    //}
    private final String message;

    public SubmissionMessageEdited(String username, int submissionId, String message) {
        this.username = username;
        this.submissionId = submissionId;
        this.message = message;
    }

    @UrlIdentifier @NotNull
    public String getUsername() {
        return username;
    }

   @Min(1)
   public int getSubmissionId() {
        return submissionId;
    }

    @Length(max = 4096) @NotNull
    public String getMessage() {
        return message;
    }

    public String getFullSubmissionId() {
        return username+"/"+submissionId;
    }

    @Override
    public String toString() {
        return "SubmissionMessageEdited{" +
                "username='" + username + '\'' +
                ", submissionId='" + submissionId + '\'' +
                ", message='" + message + '\'' +
                '}';
    }
}
